package com.hushao.aimi.vo;


import com.hushao.aimi.entity.AimiUser;

import lombok.Data;


import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;

import java.time.LocalDateTime;


/**
 * @description: 用户信息Vo
 * @author: 胡少
 * @create: 2018-06-16 12:18
 **/
@Data
public class UserVo implements Serializable {
    private String id;

    @NotNull(message = "用户名不能为空")
    private String username;

    private String password;
    private String image;
    @Pattern(regexp = "^[1](([3][0-9])|([4][5,7,9])|([5][^4,6,9])|([6][6])|([7][3,5,6,7,8])|([8][0-9])|([9][8,9]))[0-9]{8}$",message = "手机号码格式错误")
    private String phone;
    @Email(message = "邮箱格式错误")
    private String email;
    private byte status;
    private Integer roleId;
    private LocalDateTime createTime;
    private LocalDateTime updateTime;

    protected UserVo(){}

    public UserVo( String username, String image, String phone, String email) {
        this.username = username;
        this.image = image;
        this.phone = phone;
        this.email = email;
    }

    public UserVo(String id, String username, String phone, String email, byte status, Integer roleId, LocalDateTime createTime, LocalDateTime updateTime) {
        this.id = id;
        this.username = username;
        this.phone = phone;
        this.email = email;
        this.status = status;
        this.roleId = roleId;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }


    public static UserVo getUserVo(AimiUser user){
        UserVo userVo= new UserVo(user.getUsername(),user.getImage(),user.getPhone(),user.getEmail());
        return userVo;
    }

    public UserVo(String id, String username, String password, String image, String phone, String email, byte status, Integer roleId, LocalDateTime createTime, LocalDateTime updateTime) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.image = image;
        this.phone = phone;
        this.email = email;
        this.status = status;
        this.roleId = roleId;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }
}
